using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using MEA.AE_Data;
using MEA.AE_Data.Access;
using MEA.AE_Data.Config;

namespace MEA.AE_BusinessLogic
{
	public class BaseService : IBaseService
	{
		public delegate void InvokeProgress();

		public delegate void EngineTotalTimeUpdateHandler(string value);

		public delegate void LogFehlerHandler(string AB, string fehler);

		public delegate void AddConsoleHandler(string s, Color c, string AB);

		private const string outStr = "{0:x2}";

		private System.Threading.Timer t_testerPresent;

		private ConfigData.e_ECUID ecuId;

		private List<byte> sendList;

		private IECU_Access ecuAccess;

		private IECU_Data ecuData;

		private uint sessionKey;

		private bool tpEnabled;

		public bool ECUSideEnable;

		private ConfigSecurity.e_USBDongleTypes baseServSecurityAccessRight = ConfigSecurity.e_USBDongleTypes.Unknown;

		public AutoResetEvent ev_waitTPFinished;

		public ConfigData.e_ECUID EcuId
		{
			get
			{
				return ecuId;
			}
		}

		public IECU_Access EcuAccess
		{
			get
			{
				return ecuAccess;
			}
		}

		public IECU_Data EcuData
		{
			get
			{
				return ecuData;
			}
		}

		public event LogFehlerHandler ev_LogFehler;

		public event ChangingHandler ev_ECUOnlineChange;

		public event AddConsoleHandler ev_AddConsoleEvent;

		public event EventHandler ev_ECUDataUpdated;

		public event EventHandler ev_DTCCleared;

		public event ChangingHandler ev_ECUCautionLampChanged;

		public BaseService(ConfigData.e_ECUID i_ecuID, IECU_Access i_ecu)
		{
			sendList = new List<byte>();
			t_testerPresent = new System.Threading.Timer(TesterPresentSend, null, -1, -1);
			ecuData = new ECU_Data();
			ecuAccess = i_ecu;
			switch (i_ecuID)
			{
			case ConfigData.e_ECUID.A:
				ecuAccess.OnlineChangeECUA += ecu_OnlineChange;
				break;
			case ConfigData.e_ECUID.B:
				ecuAccess.OnlineChangeECUB += ecu_OnlineChange;
				break;
			}
			ecuId = i_ecuID;
		}

		private void ecu_OnlineChange(object sender, bool on)
		{
			if (!on)
			{
				ConfigFlash.IgnoreFlashCond = false;
				ecuData.DTCReadOut = false;
			}
			ECUSideEnable = on;
			ecuData.IsOnline = on;
			if (this.ev_ECUOnlineChange != null)
			{
				this.ev_ECUOnlineChange(this, on);
			}
		}

		public static int TransformBCDToInt(byte b)
		{
			byte b2 = (byte)(b & 0xF);
			byte b3 = (byte)(b >> 4);
			return b3 * 10 + b2;
		}

		public static byte TransformIntToBCD(int source)
		{
			if (source < 0 || source > 99)
			{
				throw new ArgumentException();
			}
			int num = source;
			int num2 = 0;
			for (int i = 0; i < 2; i++)
			{
				int num3 = num % 10;
				num2 |= num3 << i * 4;
				num /= 10;
			}
			return (byte)num2;
		}

		public static string TransformByteListToStringHex(List<byte> blist, bool leading0x)
		{
			string text = "";
			foreach (byte item in blist)
			{
				text = ((!leading0x) ? (text + string.Format("{0:X2} ", item)) : (text + string.Format("0x{0:X2} ", item)));
			}
			return text;
		}

		public static List<byte> TransformIntToByteList(uint data, int length)
		{
			List<byte> list = new List<byte>();
			switch (length)
			{
			case 4:
				list.Add((byte)((data >> 24) & 0xFF));
				list.Add((byte)((data >> 16) & 0xFF));
				list.Add((byte)((data >> 8) & 0xFF));
				list.Add((byte)(data & 0xFF));
				break;
			case 3:
				list.Add((byte)((data >> 16) & 0xFF));
				list.Add((byte)((data >> 8) & 0xFF));
				list.Add((byte)(data & 0xFF));
				break;
			case 2:
				list.Add((byte)((data >> 8) & 0xFF));
				list.Add((byte)(data & 0xFF));
				break;
			case 1:
				list.Add((byte)(data & 0xFF));
				break;
			}
			return list;
		}

		public bool ECUisOnline()
		{
			return ecuData.IsOnline;
		}

		private void ECUSerialRead()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			ecuData.EcuSerialNumber = "not available";
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reading Serial Number (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_Serial_Read)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_Serial_Read));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.ECU_Serial_Read, sendList);
				ecuData.EcuSerialNumber = "";
				for (int i = 2; i < 14; i++)
				{
					ecuData.EcuSerialNumber += TransformBCDToInt(list[i]).ToString("00");
				}
				ecuData.EcuHwVersionCode = (ushort)(TransformBCDToInt(list[2]) * 10 + TransformBCDToInt((byte)(list[3] >> 4)));
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("ECU Serial Number: " + ecuData.EcuSerialNumber, Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				ecuData.EcuHwVersionCode = 0;
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				ecuData.EcuHwVersionCode = 0;
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
				ecuData.EcuHwVersionCode = 0;
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
				ecuData.EcuHwVersionCode = 0;
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void EngineSerialRead()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			ecuData.EngineSerialNumber = "not available";
			ecuData.EngineType = "not available";
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reading Engine Serial Number (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Serial_Read)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Serial_Read));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Engine_Serial_Read, sendList);
				ecuData.EngineSerialNumber = "";
				try
				{
					for (int i = 2; i < 18; i++)
					{
						ecuData.EngineSerialNumber += (char)list[i];
					}
				}
				catch
				{
				}
				if (ecuData.EngineSerialNumber.Length >= 4)
				{
					string[] array = ecuData.EngineSerialNumber.Split('-');
					if (array.Length == 3)
					{
						ecuData.EngineType = array[0] + "-" + array[1];
					}
				}
				if (ecuData.EngineSerialNumber == "" || ecuData.EngineSerialNumber.Length == 0)
				{
					ecuData.EngineSerialNumber = "not available";
				}
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Engine Serial Number: " + ecuData.EngineSerialNumber, Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		private void ECUSoftwareVersionRead()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			ecuData.EcuSwVersion = "not available";
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reading Software Version (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_SWVersion)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_SWVersion));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.ECU_SWVersion, sendList);
				byte[] array = new byte[100];
				for (int i = 0; i < 100; i++)
				{
					array[i] = list[i + 2];
				}
				ecuData.EcuSwVersion = Encoding.ASCII.GetString(array, 0, 100);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Software-Version: " + ecuData.EcuSwVersion, Color.Black, "            ");
					string[] array2 = ecuData.EcuSwVersion.Split('_');
					if (array2[0].Contains("VC33"))
					{
						int result;
						if (int.TryParse(array2[2], out result))
						{
							switch (result)
							{
							case 5:
								ConfigData.ecuSwVersion = ConfigData.ECUSWVERSION.e_ECU_VER_33_009;
								ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCLess23;
								break;
							case 6:
							{
								ConfigData.ecuSwVersion = ConfigData.ECUSWVERSION.e_ECU_VER_33_06;
								string[] array3 = array2[3].Split(' ');
								if (int.Parse(array3[0]) >= 23)
								{
									ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCMore23;
								}
								else
								{
									ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCLess23;
								}
								break;
							}
							case 7:
								ConfigData.ecuSwVersion = ConfigData.ECUSWVERSION.e_ECU_VER_33_07;
								ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCMore23;
								break;
							default:
								ConfigData.ecuSwVersion = ConfigData.ECUSWVERSION.e_ECU_VER_33_009;
								ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCLess23;
								if (result > 3)
								{
									ConfigData.ecuSwVersion = ConfigData.ECUSWVERSION.e_ECU_ERR_VERSION;
									ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCMore23;
								}
								break;
							}
						}
						else
						{
							ConfigData.ecuSwVersion = ConfigData.ECUSWVERSION.e_ECU_VER_33_009;
							ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCLess23;
						}
					}
					else
					{
						ConfigData.ecuSwVersion = ConfigData.ECUSWVERSION.e_ECU_VER_33_009;
						ConfigData.ecuSwVerDTC = ConfigData.ECUSWVERDTC.eECUSWVERDTCLess23;
					}
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ArgumentOutOfRangeException arg)
			{
				Console.WriteLine("Error {0}", arg);
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void RTCRead()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			ecuData.RealTimeClock_string = "not available";
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reading Real Time Clock (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.RTC_Read)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.RTC_Read));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.RTC_Read, sendList);
				if (list.Count > 5)
				{
					ecuData.RealTimeClock_string = string.Format("{0:x2}", list[4]) + "." + string.Format("{0:x2}", list[3]) + "." + string.Format("{0:x2}", list[2]) + " " + string.Format("{0:x2}", list[5]) + ":" + string.Format("{0:x2}", list[6]) + ":" + string.Format("{0:x2}", list[7]);
					try
					{
						ecuData.RealTimeClock = new DateTime(2000 + TransformBCDToInt(list[2]), TransformBCDToInt(list[3]), TransformBCDToInt(list[4]), TransformBCDToInt(list[5]), TransformBCDToInt(list[6]), TransformBCDToInt(list[7]));
						Console.WriteLine("ecuData.RealTimeClock = {0}", ecuData.RealTimeClock);
					}
					catch
					{
						ecuData.RealTimeClock = DateTime.Now;
					}
				}
				else
				{
					Console.WriteLine("ConfigKWP.e_kwpServices.RTC_Read responseList.Count = {0} !!!", list.Count);
				}
				if (this.ev_ECUDataUpdated != null)
				{
					this.ev_ECUDataUpdated(this, null);
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void testRail_HiPresTstCriteria()
		{
			List<byte> list = new List<byte>();
			string text = "";
			sendList.Clear();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Test HiPres Test criteria ", Color.Black, string.Concat("ECU ", EcuId, ": "));
			}
			try
			{
				if (list.Count <= 0)
				{
					return;
				}
				for (int i = 0; i < list.Count; i++)
				{
					text = text + string.Format("{0:x2}", list[i]) + "   ";
				}
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Response: " + text + "h", Color.Black, "            ");
				}
				if (list.Count <= 16)
				{
					return;
				}
				text = string.Empty;
				for (int j = 12; j < 14; j++)
				{
					text = text + string.Format("{0:x2}", list[j]) + "   ";
				}
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Rail_stRefHpTst = " + text + "h", Color.Black, "            ");
				}
				ushort num = (ushort)((list[12] << 8) + list[13]);
				if (num <= 0)
				{
					return;
				}
				for (int k = 0; k < 13; k++)
				{
					if ((num & 1) == 1)
					{
						switch (k)
						{
						case 0:
							text = "Bit Pos 1. Fid_HpTst_mp.0 == 1";
							break;
						case 4:
							text = "Bit Pos 4. APPCD_rAPP1UnFlt < Rail_rAccPedHpTst_C";
							break;
						case 5:
							text = "Bit Pos 5. Rail_stCtlLoop == 5";
							break;
						case 6:
							text = "Bit Pos 6. Eng_nAvrg <> LIGov_nSetPointWarm_C +/- Rail_nDiffMaxHpTst_C";
							break;
						case 7:
							text = "Bit Pos 7. CTSCD_tClnt => Rail_tClntMinHpTst_C";
							break;
						case 9:
							text = "Bit Pos 9. InjCtl_qSetUnBal < Rail_qAvrgHpTst_mp + Rail_qDiffMaxHpTst_C\n&& InjCtl_qSetUnBal > Rail_qAvrgHpTst_mp - Rail_qDiffMaxHpTst_C";
							break;
						case 10:
							text = "Bit Pos 10. Eng_nAvrg <= Rail_nHpTst[%] + Rail_nDiffMaxHpTst_C\n&& Eng_nAvrg >= Rail_nHpTst[%] - Rail_nDiffMaxHpTst_C";
							break;
						case 11:
							text = "Bit Pos 11. RailCD_pPeak <= Rail_pSetMinHpTst + Rail_pDiffMaxHpTst_C";
							break;
						case 12:
							text = "Bit Pos 12. RailCD_pPeak >= Rail_pSetMinHpTst - Rail_pDiffMaxHpTst_C";
							break;
						default:
							text = string.Empty;
							break;
						}
						if (text != "" && this.ev_AddConsoleEvent != null)
						{
							this.ev_AddConsoleEvent(text, Color.Black, "            ");
						}
					}
					num >>= 1;
				}
			}
			catch (ECUSendErrorException)
			{
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			}
			catch (ECUResponseTimeoutException)
			{
			}
			catch (ECUResponseNegativeException)
			{
			}
			catch (ECUResponseUnkownException)
			{
			}
		}

		public DTC[] DTCListRead()
		{
			DTC[] array = new DTC[0];
			List<int> list = new List<int>();
			TesterPresentHalt();
			List<byte> list2 = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_List));
			try
			{
				list2 = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.DTC_List, sendList);
				list.Clear();
				int num = list2[1];
				for (int i = 0; i < num * 3; i += 3)
				{
					int item = list2[i + 2] * 256 + list2[i + 3];
					list.Add(item);
				}
				array = new DTC[list.Count];
				array = DTCDetailRead(list);
				ecuData.DTCReadOut = true;
			}
			catch (ECUSendErrorException)
			{
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return array;
			}
			catch (ECUResponseTimeoutException)
			{
				return array;
			}
			catch (ECUResponseNegativeException)
			{
			}
			catch (ECUResponseUnkownException)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			EcuData.DTCArray = array;
			return array;
		}

		public int[,] Statistics_Read()
		{
			List<byte> list = new List<byte>();
			int[,] array = new int[8, 8];
			TesterPresentHalt();
			SecuritySeedKey(1);
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Statistics_Read));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Statistics_Read, sendList);
				try
				{
					for (int i = 0; i < 8; i++)
					{
						for (int j = 0; j < 8; j++)
						{
							array[i, j] = 0;
							for (int k = 0; k < 4; k++)
							{
								array[i, j] |= list[i * 32 + j * 4 + k + 2] << 8 * (3 - k);
							}
							if (this.ev_AddConsoleEvent != null)
							{
								this.ev_AddConsoleEvent(ConfigStatistics.TimerTextArray[i] + " [" + (1 + j) + "] : " + TransformSecToTime(array[i, j]), Color.Black, "            ");
							}
						}
					}
				}
				catch (Exception)
				{
				}
			}
			catch (ECUSendErrorException)
			{
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "Statistics");
				}
				return array;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "Statistics");
				}
				return array;
			}
			catch (ECUResponseNegativeException)
			{
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "Statistics");
				}
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "Statistics");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			ecuData.Statistics = array;
			return array;
		}

		private void TesterPresentSend(object ob)
		{
			new List<byte>();
			if (!ecuData.IsOnline || !tpEnabled)
			{
				return;
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Tester_Present));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Tester_Present, sendList);
			}
			catch (ECUSendErrorException)
			{
			}
			catch (ECUResponseTimeoutException)
			{
				TesterPresentHalt();
			}
			catch (ECUResponseNegativeException)
			{
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
		}

		public void TesterPresentHalt()
		{
			tpEnabled = false;
			ev_waitTPFinished = new AutoResetEvent(false);
			t_testerPresent.Change(-1, -1);
		}

		public void TesterPresentStart(int time)
		{
			t_testerPresent = new System.Threading.Timer(TesterPresentSend, null, time, time);
			tpEnabled = true;
		}

		public void EngineInfoUpdate()
		{
			ECUSerialRead();
			EngineSerialRead();
			ECUSoftwareVersionRead();
			EngineUptimeRead();
			RTCRead();
			if (this.ev_ECUDataUpdated != null)
			{
				this.ev_ECUDataUpdated(this, null);
			}
		}

		public void EngineInfoUpdateXML(Stream mstream)
		{
			Stream stream = new MemoryStream();
			Stream stream2 = new MemoryStream();
			Xml_Log xml_Log = new Xml_Log();
			mstream.Position = 0L;
			byte[] array = new byte[mstream.Length];
			while (true)
			{
				int num = mstream.Read(array, 0, array.Length);
				if (num <= 0)
				{
					break;
				}
				stream.Write(array, 0, num);
				stream2.Write(array, 0, num);
			}
			stream.Position = 0L;
			stream2.Position = 0L;
			string[] array2 = xml_Log.ReadEECUID(stream, ecuId.ToString());
			ecuData.EcuSerialNumber = array2[1];
			ecuData.EcuHwVersionReadable = array2[2];
			ecuData.EcuSwVersion = array2[3];
			ecuData.TotalECUPwrOnTime = array2[4];
			ecuData.TotalECUEngineControlTime = array2[5];
			if (array2[6].Contains("UTC"))
			{
				array2[6] = array2[6].Remove(array2[6].IndexOf("UTC"));
			}
			EcuData.RealTimeClock_string = array2[6];
			string[] array3 = xml_Log.ReadEngineID(stream2, ecuId.ToString());
			ecuData.EngineSerialNumber = array3[1];
			ecuData.EngineType = array3[0];
			EcuData.TotalEngineTime = array3[2];
			if (this.ev_ECUDataUpdated != null)
			{
				this.ev_ECUDataUpdated(this, null);
			}
		}

		public void EngineTotalEngineTimeUpdate(string totalTime)
		{
			ecuData.TotalEngineTime = totalTime;
			if (this.ev_ECUDataUpdated != null)
			{
				this.ev_ECUDataUpdated(this, null);
			}
		}

		public void ErrorReportNegResponse(byte fehlerid)
		{
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Negative Response: ", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			switch (fehlerid)
			{
			case 16:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("General reject", Color.Black, "            ");
				}
				break;
			case 18:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Invalid format", Color.Black, "            ");
				}
				break;
			case 34:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Condition is not correct or request sequence error", Color.Black, "            ");
				}
				break;
			case 49:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Request out of range", Color.Black, "            ");
				}
				break;
			case 51:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Security access denied", Color.Black, "            ");
				}
				break;
			case 53:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Invalid key", Color.Black, "            ");
				}
				break;
			case 254:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Programming error", Color.Black, "            ");
				}
				break;
			default:
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent(string.Format("{0:x2}", fehlerid), Color.Black, "            ");
				}
				break;
			}
		}

		public void CommunicationReStart(uint diag)
		{
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Start Communication (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Communication_Start)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Communication_Start));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Communication_Start, sendList);
				try
				{
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Positive Response: Key Bytes: {0:x2}{1:x2}", list[1], list[2]), Color.Black, "            ");
					}
					sessionKey = list[2];
					ecuData.IsOnline = true;
					Diagnose_stop();
					Diagnose_start(diag);
				}
				catch (Exception)
				{
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseNegativeException ex4)
			{
				ErrorReportNegResponse(Convert.ToByte(ex4.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void CommunicationStart(bool disableTimeoutMessage)
		{
			TesterPresentHalt();
			ecuAccess.ConnectUSB();
			if (ecuData.IsOnline)
			{
				return;
			}
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Start Communication (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Communication_Start)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Communication_Start));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Communication_Start, sendList);
				try
				{
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Positive Response: Key Bytes: {0:x2}{1:x2}", list[1], list[2]), Color.Black, "            ");
					}
					sessionKey = list[2];
					ecuData.IsOnline = true;
					SecuritySeedKey(1);
					Diagnose_stop();
					Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
					EngineInfoUpdate();
				}
				catch (Exception)
				{
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				if (!disableTimeoutMessage)
				{
					MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseNegativeException ex4)
			{
				ErrorReportNegResponse(Convert.ToByte(ex4.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void CommunicationStop()
		{
			new List<byte>();
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Disconnecting (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Communication_Stop)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Communication_Stop));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Communication_Stop, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("accepted", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			ecuData.IsOnline = false;
		}

		public void USBDongleClose()
		{
			ecuAccess.DisconnectUSB();
		}

		public void Diagnose_start(uint mode)
		{
			List<byte> list = new List<byte>();
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Start Diagnostic Session: Mode " + string.Format("{0:x2}", mode) + " ...", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Diagnostic_Start));
			sendList.Add((byte)mode);
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Diagnostic_Start, sendList);
				if (list.Count > 1 && this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Diagnostic Session: Mode " + string.Format("{0:x2}", mode) + " started", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void Diagnose_stop()
		{
			new List<byte>();
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Stop Diagnostic Session (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Diagnostic_Stop)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Diagnostic_Stop));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Diagnostic_Stop, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("accepted", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public List<byte> AuxService(ConfigKWP.e_kwpServices sid, List<byte> additionalSendlist)
		{
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(sid));
			sendList.AddRange(additionalSendlist);
			return ecuAccess.Query(ecuId, sid, sendList);
		}

		public void AuxService(ConfigKWP.e_kwpServices sid, List<byte> additionalSendlist, ref List<byte> responseList)
		{
			try
			{
				sendList.Clear();
				sendList.AddRange(ConfigKWP.SendList(sid));
				sendList.AddRange(additionalSendlist);
				responseList = ecuAccess.Query(ecuId, sid, sendList);
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				responseList = new List<byte> { 127, 127 };
			}
		}

		public void SecuritySeedKey(byte mode)
		{
			List<byte> list = new List<byte>();
			uint num = 0u;
			byte[] array = new byte[4];
			uint[,] array2 = new uint[8, 4];
			string text;
			switch (mode)
			{
			default:
				return;
			case 1:
				array2 = ConfigKWP.UKey_DiagMask_cu8;
				text = "Diagnostic";
				break;
			case 5:
				array2 = ConfigKWP.UKey_FlashMask_cu8;
				text = "Flash";
				break;
			}
			if (!ecuData.IsOnline)
			{
				return;
			}
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent(string.Format("Request Security Access (SID 0x{0:X2})", ConfigKWP.SendList(ConfigKWP.e_kwpServices.SecuritySeedKey)[0]), Color.Black, string.Format("ECU {0}:  ", ecuId));
				this.ev_AddConsoleEvent(string.Format("Access mode 0x{0:X2}", mode), Color.Black, "            ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.SecuritySeedKey));
			sendList.Add(mode);
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.SecuritySeedKey, sendList);
				try
				{
					num |= list[2];
					num <<= 8;
					num |= list[3];
					num <<= 8;
					num |= list[4];
					num <<= 8;
					num |= list[5];
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Seed {0:X2} {1:X2} {2:X2} {3:X2}", list[2], list[3], list[4], list[5]), Color.Black, "            ");
					}
					if (num == 0)
					{
						if (this.ev_AddConsoleEvent != null)
						{
							this.ev_AddConsoleEvent(string.Format("Already unlocked {0}-Security-Mode ", text), Color.Black, "            ");
						}
						return;
					}
					for (int i = 2; i < 6; i++)
					{
						array[i - 2] = list[i];
						if (i != 5)
						{
							array[i - 2] = (byte)(list[i] >> (list[i + 1] & 3));
						}
						array[i - 2] = (byte)(array[i - 2] ^ array2[array[i - 2] & 7, array[i - 2] & 3]);
					}
				}
				catch (Exception)
				{
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
			}
			catch (ECUResponseNegativeException ex4)
			{
				ErrorReportNegResponse(Convert.ToByte(ex4.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.SecuritySeedKey));
			mode++;
			sendList.Add(mode);
			sendList.Add(array[0]);
			sendList.Add(array[1]);
			sendList.Add(array[2]);
			sendList.Add(array[3]);
			try
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Sending key " + string.Format("{0:X2}", array[0]) + " " + string.Format("{0:X2}", array[1]) + " " + string.Format("{0:X2}", array[2]) + " " + string.Format("{0:X2}", array[3]), Color.Black, "            ");
				}
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Access mode " + string.Format("0x{0:X2}", mode), Color.Black, "            ");
				}
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.SecuritySeedKey, sendList);
				try
				{
					if (list[1] == mode && list[2] == 52)
					{
						if (this.ev_AddConsoleEvent != null)
						{
							this.ev_AddConsoleEvent(text + "-Security-Mode succesfully unlocked", Color.Black, "            ");
						}
					}
					else if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
					}
				}
				catch (Exception)
				{
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
			}
			catch (ECUResponseNegativeException ex9)
			{
				ErrorReportNegResponse(Convert.ToByte(ex9.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
		}

		private void EngineUptimeRead()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			double num = 0.0;
			double num2 = 0.0;
			double totalECUEngineControlTime_raw = 0.0;
			bool flag = false;
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reading Engine Uptimes (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Uptime_Read)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Uptime_Read));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Engine_Uptime_Read, sendList);
				for (int i = 0; i < 4; i++)
				{
					num += (double)(int)list[i + 6] * Math.Pow(256.0, 3 - i);
					num2 += (double)(int)list[i + 10] * Math.Pow(256.0, 3 - i);
					totalECUEngineControlTime_raw = num2;
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
				flag = true;
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			ecuData.TotalECUPwrOnTime = TransformSecToTime(num);
			ecuData.TotalECUEngineControlTime = TransformSecToTime(num2);
			ecuData.TotalECUEngineControlTime_raw = totalECUEngineControlTime_raw;
			if (flag)
			{
				ecuData.TotalECUEngineControlTime = "not available";
				ecuData.TotalECUPwrOnTime = "not available";
			}
		}

		public string TransformSecToTime(double zeit)
		{
			int num = (int)zeit;
			int num2 = num / 3600;
			int num3 = num % 3600;
			int num4 = num3 / 60;
			num3 = num % 60;
			return num2 + " h " + num4 + " m " + num3 + " s";
		}

		private DTC[] DTCDetailRead(List<int> errorIndeces)
		{
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reading DTC (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_Detail)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			DTC[] array = new DTC[errorIndeces.Count];
			int num = 0;
			foreach (int errorIndece in errorIndeces)
			{
				List<byte> list = new List<byte>();
				sendList.Clear();
				sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_Detail));
				byte b = (byte)(errorIndece >> 8);
				byte b2 = (byte)(errorIndece & 0xFF);
				sendList.Add(b);
				sendList.Add(b2);
				try
				{
					list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.DTC_Detail, sendList);
					switch (list[1])
					{
					case 0:
						if (this.ev_AddConsoleEvent != null)
						{
							this.ev_AddConsoleEvent(string.Format("{0:x2}", b) + string.Format("{0:x2}", b2) + ": DTC not entered in the fault code memory", Color.Black, "            ");
						}
						break;
					case 1:
						try
						{
							int id = list[2] * 256 + list[3];
							int freq = Convert.ToInt32(list[8]);
							int errTyp_first = list[9];
							int errTyp_last = list[19];
							bool act = false;
							bool cl = false;
							if ((list[4] & 0x60) == 96)
							{
								act = true;
							}
							if ((list[4] & 0x80) > 0)
							{
								cl = true;
							}
							byte[] array2 = new byte[9];
							byte[] array3 = new byte[9];
							for (int i = 0; i < 9; i++)
							{
								array2[i] = list[i + 10];
							}
							for (int j = 0; j < 9; j++)
							{
								array3[j] = list[j + 20];
							}
							try
							{
								DTC dTC = ConfigData.GetDTC(id);
								if (dTC.id == 65535)
								{
									dTC.id = id;
								}
								else if (dTC.id == 7935)
								{
									int id2 = array2[0] * 256 + array2[1];
									errTyp_first = array2[2];
									errTyp_last = array3[2];
									dTC = ConfigData.GetDTC(id2);
								}
								dTC.freq = freq;
								array[num] = dTC.CloneNewStatus(errTyp_first, errTyp_last, act, cl, array2, array3);
								if (this.ev_AddConsoleEvent != null)
								{
									this.ev_AddConsoleEvent(array[num].ToString(), Color.Black, "            ");
								}
							}
							catch (Exception)
							{
								if (this.ev_AddConsoleEvent != null)
								{
									this.ev_AddConsoleEvent("Error during decoding of DTC " + id, Color.Black, "            ");
								}
							}
						}
						catch (Exception)
						{
						}
						break;
					}
				}
				catch (ECUSendErrorException)
				{
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
					}
					return array;
				}
				catch (ECUResponseTimeoutException)
				{
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
					}
					MessageBox.Show("Timeout error ECU " + ecuId.ToString() + "\nCheck your CAN device and ECU power supply", ConfigData.WizardSwName);
					return array;
				}
				catch (ECUResponseNegativeException ex5)
				{
					ErrorReportNegResponse(Convert.ToByte(ex5.Message));
				}
				catch (ECUResponseUnkownException)
				{
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("{0:x2}", b) + string.Format("{0:x2}", b2) + ": Unknown Response", Color.Black, "            ");
					}
					return array;
				}
				num++;
			}
			return array;
		}

		public ConfigSecurity.e_USBDongleTypes BaseServSecurityAccessRight()
		{
			return baseServSecurityAccessRight;
		}

		public void SecurityDetectAccessRights(bool informUser)
		{
			if (ecuAccess.CheckDongleCode(ConfigSecurity.DongleCode(ConfigSecurity.e_USBDongleTypes.OEM)) == 1)
			{
				baseServSecurityAccessRight = ConfigSecurity.e_USBDongleTypes.OEM;
				return;
			}
			if (ecuAccess.CheckDongleCode(ConfigSecurity.DongleCode(ConfigSecurity.e_USBDongleTypes.Qualified_Maintainance)) == 1)
			{
				baseServSecurityAccessRight = ConfigSecurity.e_USBDongleTypes.Qualified_Maintainance;
				return;
			}
			if (ecuAccess.CheckDongleCode(ConfigSecurity.DongleCode(ConfigSecurity.e_USBDongleTypes.Maintainance)) == 1)
			{
				baseServSecurityAccessRight = ConfigSecurity.e_USBDongleTypes.Maintainance;
				return;
			}
			if (ecuAccess.CheckDongleCode(ConfigSecurity.DongleCode(ConfigSecurity.e_USBDongleTypes.WDAE)) == 1)
			{
				baseServSecurityAccessRight = ConfigSecurity.e_USBDongleTypes.WDAE;
				return;
			}
			if (ecuAccess.CheckDongleCode(ConfigSecurity.DongleCode(ConfigSecurity.e_USBDongleTypes.Lite)) == 1)
			{
				baseServSecurityAccessRight = ConfigSecurity.e_USBDongleTypes.Lite;
				return;
			}
			baseServSecurityAccessRight = ConfigSecurity.e_USBDongleTypes.Unknown;
			if (informUser)
			{
				MessageBox.Show("No valid CAN device connected.", ConfigData.WizardSwName);
			}
		}

		public void DTCClear()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_Clear));
			try
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Clear Fault Code Memory (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_Clear)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
				}
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.DTC_Clear, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("accepted", Color.Black, "            ");
				}
				ecuData.DTCReadOut = false;
				ecuData.DTCArray = new DTC[0];
				if (this.ev_DTCCleared != null)
				{
					this.ev_DTCCleared(this, null);
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void DTCOff()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			Diagnose_stop();
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Disabling DTC check (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_Off)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_Off));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.DTC_Off, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("accepted", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "DTC disable");
				}
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "DTC disable");
				}
				return;
			}
			catch (ECUResponseNegativeException)
			{
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "DTC check disable");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void DTCOn()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			Diagnose_stop();
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
			TesterPresentHalt();
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_On));
			try
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Enabling DTC check (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.DTC_On)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
				}
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.DTC_On, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("accepted", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unable to send request", Color.Black, "            ");
				}
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "DTC enable");
				}
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "DTC enable");
				}
				return;
			}
			catch (ECUResponseNegativeException)
			{
				if (this.ev_LogFehler != null)
				{
					this.ev_LogFehler(ecuId.ToString(), "DTC check enable");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void IQAInitialize1(bool coding)
		{
			ecuData.IQAInitStep1Done = false;
			TesterPresentHalt();
			if (coding)
			{
				SecuritySeedKey(1);
			}
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Initialize IQA Step 1 (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_Init_1)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_Init_1));
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.IQA_Init_1, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent(string.Format("{0:x2} {1:x2} {2:x2} {3:x2} {4:x2} {5:x2} {6:x2} {7:x2} {8:x2}", list[2], list[3], list[4], list[5], list[6], list[7], list[8], list[9], list[10]), Color.Black, "            ");
				}
				if (coding)
				{
					ECUCodingWrite();
				}
				else
				{
					ecuData.IQAInitStep1Done = true;
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Initialize IQA: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Initialize IQA: Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void IQAInitialize2()
		{
			ecuData.IQAInitStep2Done = false;
			TesterPresentHalt();
			SecuritySeedKey(1);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Initialize IQA Step 2: Initializing IQA codes for all Cylinders  (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_Init_2)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_Init_2));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.IQA_Init_2, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write IQA code: Success", Color.Black, "            ");
				}
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Initialize IQA: completed", Color.Black, "            ");
				}
				ecuData.IQAInitStep2Done = true;
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write IQA code: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void RecManFormat1()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			Diagnose_stop();
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.MemoryAccess));
			TesterPresentHalt();
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Format_DatLogEvRec_1));
			try
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Erase Data Logger and Event Recorder fblock...", Color.Black, "            ");
				}
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Format_DatLogEvRec_1, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Erase Data Logger and Event Recorder fblock: success", Color.Black, "            ");
				}
				RecManFormat2();
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Erase fblock: Unable to send request", Color.Black, "            ");
				}
				Diagnose_stop();
				Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void RecManFormat2()
		{
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Format Data Logger fblock (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Format_DatLogEvRec_2_1)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Format_DatLogEvRec_2_1));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Format_DatLogEvRec_2_1, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Data Logger fblock: success", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Data Logger fblock: Unable to send request", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Format Event Recorder fblock (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Format_DatLogEvRec_2_2)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Format_DatLogEvRec_2_2));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Format_DatLogEvRec_2_2, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Event Recorder fblock: success", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Event Recorder fblock: Unable to send request", Color.Black, "            ");
				}
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
			}
			catch (ECUResponseNegativeException ex7)
			{
				ErrorReportNegResponse(Convert.ToByte(ex7.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
		}

		public void LIDDataWrite()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Write Data by LID (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.LID_Data_Write)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.LID_Data_Write));
			byte[] array = new byte[8];
			for (int i = 0; i < 8; i++)
			{
				array[i] = 0;
			}
			sendList.AddRange(array);
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.LID_Data_Write, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Data by LID", Color.Black, "            ");
				}
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Statistics reset", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null && this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Data by LID: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void IQAReadCyl(int nr)
		{
			ecuData.EngineType.Split();
			string[] array = new string[4];
			TesterPresentHalt();
			SecuritySeedKey(1);
			int num = 1;
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_ReadCylinder));
			if (nr == 72)
			{
				num = 4;
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Read IQA code for all Cylinders (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_ReadCylinder)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
				}
			}
			else if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Read IQA code for Cylinder" + (nr - 63) + " (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_ReadCylinder)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Add((byte)nr);
			sendList.Add(1);
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.IQA_ReadCylinder, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("IQA code read out:", Color.Black, "            ");
				}
				byte[] array2 = new byte[5];
				IMA iMA = new IMA();
				for (int i = 0; i < num; i++)
				{
					for (int j = 0; j < 5; j++)
					{
						array2[j] = list[i * 5 + j + 3];
					}
					array[i] = iMA.vonBytesToString(array2);
					if (nr == 72 && this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Cylinder {0:d}: {1}", i + 1, array[i]), Color.Black, "            ");
					}
				}
				switch (nr)
				{
				case 72:
					ecuData.IQACylRead[0] = array[0];
					ecuData.IQACylRead[1] = array[1];
					ecuData.IQACylRead[2] = array[2];
					ecuData.IQACylRead[3] = array[3];
					break;
				case 64:
					ecuData.IQACylRead[0] = array[0];
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Cylinder 1: {0}", array[0]), Color.Black, "            ");
					}
					break;
				case 65:
					ecuData.IQACylRead[1] = array[0];
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Cylinder 2: {0}", array[0]), Color.Black, "            ");
					}
					break;
				case 66:
					ecuData.IQACylRead[2] = array[0];
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Cylinder 3: {0}", array[0]), Color.Black, "            ");
					}
					break;
				case 67:
					ecuData.IQACylRead[3] = array[0];
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("Cylinder 4: {0}", array[0]), Color.Black, "            ");
					}
					break;
				case 68:
				case 69:
				case 70:
				case 71:
					break;
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Read IQA code Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void IQAWriteCyl(int nr, byte[] code)
		{
			bool flag = true;
			TesterPresentHalt();
			SecuritySeedKey(1);
			List<byte> list = new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.IQA_WriteCylinder));
			sendList.Add((byte)nr);
			sendList.Add(8);
			sendList.AddRange(code);
			try
			{
				list = ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.IQA_WriteCylinder, sendList);
				if (list[0] == 112)
				{
					for (int i = 0; i < code.Length; i++)
					{
						if (list[i + 3] != code[i])
						{
							flag = false;
						}
					}
					if (flag)
					{
						if (this.ev_AddConsoleEvent != null)
						{
							this.ev_AddConsoleEvent(string.Format("ECU: {0} Write IQA code: Success", ecuId), Color.Black, "            ");
						}
					}
					else if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent("Write IQA code: Not Success", Color.Red, "            ");
					}
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write IQA code: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void ECU_Reset()
		{
			new List<byte>();
			TesterPresentHalt();
			Diagnose_stop();
			SecuritySeedKey(5);
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Flash));
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reset ECU (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_Reset)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_Reset));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.ECU_Reset, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Reset ECU: Success", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Reset ECU : Unable to send request", Color.Black, "            ");
				}
				Diagnose_stop();
				Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				try
				{
					Diagnose_stop();
					Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
					return;
				}
				catch
				{
					return;
				}
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			ecuData.IsOnline = false;
		}

		public void EngineUptime_Reset()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reset Engine Uptimes (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Uptime_Reset)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Uptime_Reset));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Engine_Uptime_Reset, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Engine uptimes reset", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Reset Engine Uptimes : Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void Statistics_Reset()
		{
			new List<byte>();
			TesterPresentHalt();
			SecuritySeedKey(1);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reset Statistics (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Statistics_Reset)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Statistics_Reset));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Statistics_Reset, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Statistics reset", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Reset Statistics : Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void EngineSerialWrite(byte[] serial)
		{
			new List<byte>();
			TesterPresentHalt();
			SecuritySeedKey(1);
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Set Engine Serial Number (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Serial_Write)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.Engine_Serial_Write));
			sendList.AddRange(serial);
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.Engine_Serial_Write, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Engine Serial Number set", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Set Engine Serial Number: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void RTCWrite(byte[] time)
		{
			new List<byte>();
			TesterPresentHalt();
			SecuritySeedKey(1);
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Set Real Time Clock (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.RTC_Write)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.RTC_Write));
			sendList.AddRange(time);
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.RTC_Write, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Real Time Clock set", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Set Real Time Clock: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Comment:", Color.Red, null);
			}
		}

		public void RecManDatLogConfig_Read()
		{
			List<byte> list = new List<byte>();
			TesterPresentHalt();
			SecuritySeedKey(1);
			Diagnose_stop();
			Diagnose_start(ConfigKWP.DiagMode_Get(ConfigKWP.e_DiagModes.Diagnostic));
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Reading DataLogger Configuration...", Color.Black, string.Concat("ECU ", EcuId, ":  "));
			}
			try
			{
				list = AuxService(ConfigKWP.e_kwpServices.DatLog_Config_Read, new List<byte>());
				uint recInterval = list[2];
				List<byte[]> list2 = new List<byte[]>();
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("DataLogger Configuration read out:", Color.Black, string.Concat("ECU ", EcuId, ":  "));
				}
				for (int i = 1; i < 35; i++)
				{
					if (this.ev_AddConsoleEvent != null)
					{
						this.ev_AddConsoleEvent(string.Format("{0:x2}", list[i]), Color.Black, string.Concat("ECU ", EcuId, ":  "));
					}
					if (i > 2 && i % 2 != 0)
					{
						list2.Add(new byte[2]
						{
							list[i],
							list[i + 1]
						});
					}
				}
				ecuData.DatlogCfg = new DatLogCfg(recInterval, list2);
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Reading DataLogger Configuration: Unable to send request", Color.Black, string.Concat("ECU ", EcuId, ":  "));
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, string.Concat("ECU ", EcuId, ":  "));
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, string.Concat("ECU ", EcuId, ":  "));
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void RecManDatLogConfig_Write()
		{
			TesterPresentHalt();
			SecuritySeedKey(1);
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("WriteDataloggerConfig (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.DatLog_Config_Write)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.DatLog_Config_Write));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.DatLog_Config_Write, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Data Logger configuration: Success", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write Data Logger configuration: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void ECUCodingWrite()
		{
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Write ECU coding (SID 0x" + string.Format("{0:X2}", ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_Coding_Write)[0]) + ")", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			new List<byte>();
			sendList.Clear();
			sendList.AddRange(ConfigKWP.SendList(ConfigKWP.e_kwpServices.ECU_Coding_Write));
			try
			{
				ecuAccess.Query(ecuId, ConfigKWP.e_kwpServices.ECU_Coding_Write, sendList);
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Initialize IQA: Write ECU coding: Success", Color.Black, "            ");
				}
			}
			catch (ECUSendErrorException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Write ECU coding: Unable to send request", Color.Black, "            ");
				}
				TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
				return;
			}
			catch (ECUResponseTimeoutException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Timeout error", Color.Black, "            ");
				}
				return;
			}
			catch (ECUResponseNegativeException ex3)
			{
				ErrorReportNegResponse(Convert.ToByte(ex3.Message));
			}
			catch (ECUResponseUnkownException)
			{
				if (this.ev_AddConsoleEvent != null)
				{
					this.ev_AddConsoleEvent("Unknown Response", Color.Black, "            ");
				}
			}
			catch (ECUDisconnectedExeption)
			{
			}
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}

		public void ECULeaveBootMode()
		{
			TesterPresentHalt();
			if (this.ev_AddConsoleEvent != null)
			{
				this.ev_AddConsoleEvent("Waiting for ECU to quit boot-mode", Color.Black, "ECU " + ecuId.ToString() + ": ");
			}
			Thread.Sleep(5000);
			TesterPresentStart(ConfigData.TesterPresentPeriod_ms);
		}
	}
}
